<?php
$post = $_POST;
//获取用户信息
$username = isset($_GET['username']) ? $_GET['username'] : '';
$link=mysqli_connect('127.0.0.1','root','root','books-system');
mysqli_set_charset($link, 'utf8');
$query = "select * from user where username='$username'";
$result = mysqli_query($link, $query);
$data = mysqli_fetch_assoc($result);
//用户信息编辑页面
?>

<!doctype html>
<html lang="zh">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
  <link rel="icon" href="../dist/img/favicon-32x32.png" sizes="32x32" type="image/png">
  <link rel="icon" href="../dist/img/favicon-16x16.png" sizes="16x16" type="image/png">
  <meta name="keywords" content="响应式后台模板,开源免费后台模板,Bootstrap5后台管理系统模板">
  <meta name="description" content="bootstrap-admin基于bootstrap5的免费开源的响应式后台管理模板">
  <meta name="author" content="ajiho">
  <link rel="stylesheet" href="../lib/bootstrap-icons/font/bootstrap-icons.min.css">
  <link rel="stylesheet" href="../lib/bootstrap/dist/css/bootstrap.min.css">
  <link rel="stylesheet" href="../dist/css/bootstrap-admin.min.css">
  <title>bootstrap-admin开源免费响应式后台管理系统模板</title>
</head>
<body class="bg-body-tertiary py-3">
<div class="container-fluid">
<form action="user-add.php" method="post">
    <div class="card border-0 shadow-sm">
        <div class="card-header bg-body">
            用户信息更新
        </div>
        <div class="card-body">
            <form action="#user-add.php" id="form">
            <div class="mb-3">
                    <label for="username" class="form-label">用户名</label>
                    <input type="text" class="form-control" id="username" name="username" value="<?php echo $data['username']?>">
                </div>
                <div class="mb-3">
                    <label for="name" class="form-label">姓名</label>
                    <input type="text" class="form-control" id="name" name="name" value="<?php echo $data['name']?>">
                </div>

                
                <div class="mb-3">
                    <label for="password" class="form-label">密码</label>
                    <input type="text" class="form-control" id="password" name="password" value="<?php 
                    // echo $data['password']
                    
                    if (!isset($username)) {
                        echo 123456;
                    }else {
                        echo $data['password'];
                    } 
                    ?>" >
                    <div id="emailHelp" class="form-text">密码不填写默认为123456</div>

                </div>

                <!-- <div class="mb-3">
                    <label for="password_confirm" class="form-label">确认密码</label>
                    <input type="text" class="form-control" id="password_confirm"
                           name="password_confirm">
                </div> -->

                <div class="mb-3">
                    <label for="sexRadio1" class="form-label">性别</label>
                    <div>
                    <!-- <input type="text" class="form-control" id="sex" name="sex"  > -->
                    <div>
                    

                        <div class="form-check form-check-inline">
                            <input class="form-check-input" type="radio" name="sex" id="sexRadio0"
                                   value="0" <?php if($data['sex']==0) echo checked; ?> >
                            <label class="form-check-label" for="sexRadio0">保密</label>
                        </div>
                        <div class="form-check form-check-inline">
                            <input class="form-check-input" type="radio" name="sex" id="sexRadio1"
                                   value="1" <?php if($data['sex']==1) echo checked; ?> >
                            <label class="form-check-label" for="sexRadio1">男</label>
                        </div>
                        <div class="form-check form-check-inline">
                            <input class="form-check-input" type="radio" name="sex" id="sexRadio2"
                                   value="2" <?php if($data['sex']==2) echo checked; ?> >
                            <label class="form-check-label" for="sexRadio2">女</label>
                        </div>
                    </div>
                </div>
                
                <div class="mb-3">
                    <label for="phone" class="form-label">手机</label>
                    <input type="text" class="form-control" id="phone" name="phone" value="<?php echo $data['phone']; ?>">
                </div>

                <div class="mb-3">
                    <label for="emali" class="form-label">邮箱</label>
                    <input type="text" class="form-control" id="emali" name="emali"value="<?php echo $data['emali']; ?>">
                </div>
                <button type="submit" class="btn btn-primary">添加</button>
            </form>
        </div>
    </div>
</div>
</form>

</div>
<!--回到顶部开始-->
<a href="javaScript:" class="bsa-back-to-top"><i class='bi bi-arrow-up-short'></i></a>
<!--回到顶部结束-->


<script src="../lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="../lib/jquery/dist/jquery.min.js"></script>
<script src="../lib/formvalidation/js/formValidation.js"></script>
<script src="../lib/formvalidation/js/framework/bootstrap.js"></script>
<script src="../lib/formvalidation/js/language/zh_CN.js"></script>
<script src="../dist/js/bootstrap-admin.min.js"></script>
<script src="../dist/js/app.js"></script>
<!--假数据模拟,生产环境中请直接删除该js-->
<!-- <script src="../dist/js/bootstrap-admin.mock.js"></script> -->
<script>


  $("#form").formValidation({
    //验证字段
    fields: {
      name: {
        validators: {
          notEmpty: true
        }
      },
      username: {
        validators: {
          notEmpty: true
        }
      },
      //...
    }
  });

    


</script>

</body>
</html>
